package com.xander.utils;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by YE on 2018/5/4.
 */
public class PhoneNumberUtils {
    //随机生成手机号
    public static String createRandomNumber() {
        StringBuffer sb = new StringBuffer();
        sb.append("18");
        Random random = new Random();
        int s = random.nextInt(899999999) + 100000000;
        sb.append(s);
        return sb.toString();
    }
    public static String asteriskNumber(String number){
        StringBuffer sb = new StringBuffer();
        sb.append(number.substring(0, 3));
        sb.append("****");
        sb.append(number.substring(7, 11));
        return sb.toString();
    }

    public static List<String> getValidNumber(){
        List<String> list=new ArrayList<>();
        String number;
        try {
            InputStream is=PhoneNumberUtils.class.getResourceAsStream("/手机号.txt");
            BufferedReader bf=new BufferedReader(new InputStreamReader(is));
            while((number=bf.readLine())!=null){
                System.out.println(number);
                list.add(number);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }
}
